from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import text

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://postgres:difyai123456@localhost:5432/serp'
db = SQLAlchemy(app)

@app.route('/test-db-connection')
def test_db_connection():
    try:
        db.session.execute(text('SELECT 1'))
        return 'Database connection successful!'
    except Exception as e:
        return 'Database connection failed! Error: {}'.format(str(e))

if __name__ == '__main__':
    app.run(debug=True)
